package com.halflife.shiro.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by zhaoyf on 2018/2/25.
 */
@RestController
public class LoginController {
    @PostMapping("login")
    public ResponseEntity<Integer> login(String loginName,HttpServletRequest request, HttpServletResponse response) {
        UsernamePasswordToken token = new UsernamePasswordToken(loginName, loginName+"password",false);
        SecurityUtils.getSubject().login(token);
        return ResponseEntity.ok(1);
    }
}
